<?php
if( !defined( 'ACTIONALFTERSELLCREDIT' ) ): define( 'ACTIONALFTERSELLCREDIT', 1 );
if( !defined( 'FILE_ROOT' ) ) include_once( '../path.conf' );

/**
 * Table Products
 */
USE_APP('Bills');
USE_APP('Bills_customers');
include_once(APP_ROOT.'actionaftersell.class.php5');

class ActionAfterSellCredit implements ActionAfterSell
	{
	// FONCTIONS A SURCHARGER EVENTUELLEMENT
	public function doThatafterSell( $product_values, $bill )
		{
		$q = $product_values['f_quantity'] * intval(preg_replace('|([0-9]+)\+(.*)|','\\1',(base64_decode($product_values['id']))));
		$users = new Bills_Customers();
		$current = $users->selectElement($bill['bill']['f_bills_customers_id']);
		$values = array('f_points'=> ($current['f_points'] + $q));
		$users->updateThisRecord($bill['bill']['f_bills_customers_id'], $values, $trigger=true );
		}
		
	}

endif;
?>